<?php

namespace app\admin\logic;

use app\common\config\cache\CacheKey;
use Symfony\Component\Yaml\Yaml;

/**
 * Created by PhpStorm
 * USER zhangkai QQ 920062039
 * Date 2022/2/10   20:34
 */
class Authority
{
    public static function getAuthority(){
        $auths = cache(CacheKey::authority(getConfigModuleName())->key());
        if(!empty($auths)){
            return $auths;
        }

        $auths = Yaml::parseFile(app()->getAppPath().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'Authority.yml');
        $auths = $auths;

        if(!empty($auths)){
            cache(CacheKey::authority(getConfigModuleName())->key(),$auths,['expire'=>3600]);
            return $auths;
        }else{
            exception('权限不存在');
        }
    }
}